package com.everest.tribalapp;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class Desa_Form5 extends Activity implements OnClickListener
{

	private Button next;
	private Button prev;
	private TextView desa_f5_qes_1;
	private TextView desa_f5_qes_2;
	private TextView desa_f5_qes_3;
	private TextView desa_f5_qes_4;
	private TextView desa_f5_qes_5;
	private TextView desa_f5_qes_6;
	private TextView desa_f5_qes_7;
	private TextView desa_f5_qes_8;
	private TextView desa_f5_qes_9;
	private TextView desa_f5_qes_10;
	private TextView desa_f5_qes_12;
	private TextView desa_f5_qes_11;
	private TextView desa_f5_qes_13a;
	private TextView desa_f5_qes_13b;
	private EditText desa_f5_ans_1;
	private EditText desa_f5_ans_2;
	private EditText desa_f5_ans_3;
	private EditText desa_f5_ans_4;
	private EditText desa_f5_ans_6;
	private EditText desa_f5_ans_8;
	private EditText desa_f5_ans_10;
	private EditText desa_f5_ans_12;
	private EditText desa_f5_ans_11;
	private EditText desa_f5_ans_13a;
	private EditText desa_f5_ans_13b;
	private CharSequence[] MSG_VALUES_1={"Ada","Tidak ada"};
	private CharSequence[] MSG_VALUES_5={"Perbaikan peralatan","Peningkatan pelayanan","Penanganan gangguan","Perbaikan layanan"};
	private CharSequence[] MSG_VALUES_7={"Perangkat keras (hardware)","Perangkat lunak (software)"};
	private CharSequence[] MSG_VALUES_9={"Dibiarkan saja","Mencoba memperbaiki sesuai SOP","Memanggil penyedia fasilitas internet PLIK","Memanggil teknisi selain penyedia PLIK"};
	private CharSequence[] MSG_VALUES_3={"Ada","Tidak ada -> Lanjut ke No. V-6"};
	private CharSequence[] MSG_VALUES_4={"Satu kali","2 kali","3 kali","4 kali","> 4 kali"};
	private CharSequence[] MSG_VALUES_6={"Pernah ","Tidak atau belum pernah Lanjut ke No.V-11."};
	private CharSequence[] MSG_VALUES_10={"1 - 7 hari","8 - 14 hari","15 - 30 hari","> 1 Bulan","Tidak pernah datang"};
	private CharSequence[] MSG_VALUES_11={"Di lokasi perangkat","Dibawa oleh teknisi"};
	private CharSequence[] MSG_VALUES_12={"1 - 7 hari","8 - 14 hari","15 - 30 hari","> 1 Bulan","Tidak dikembalikan"};
	private CharSequence[] MSG_VALUES_13a={"Sesuai (maks Rp. 3000/jam)","Tidak sesuai. Berapa? Rp / jam"};
	protected boolean[] selectVal5={false,false,false,false};
	protected boolean[] selectVal7={false,false};
	protected boolean[] selectVal9={false,false,false,false};
	private String value="";
	private CheckBox desa_f5_ans_5a;
	private CheckBox desa_f5_ans_5b;
	private CheckBox desa_f5_ans_5c;
	private CheckBox desa_f5_ans_5d;
	private CheckBox desa_f5_ans_9a;
	private CheckBox desa_f5_ans_9b;
	private CheckBox desa_f5_ans_9c;
	private CheckBox desa_f5_ans_9d;
	private CheckBox desa_f5_ans_7a;
	private CheckBox desa_f5_ans_7b;
	@Override
	public void onBackPressed() {
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		Desa_Form5.this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.desa_f5);
		desa_f5_qes_1=(TextView)findViewById(R.id.desa_f5_qes_1);
		desa_f5_qes_2=(TextView)findViewById(R.id.desa_f5_qes_2);
		desa_f5_qes_3=(TextView)findViewById(R.id.desa_f5_qes_3);
		desa_f5_qes_4=(TextView)findViewById(R.id.desa_f5_qes_4);
		desa_f5_qes_5=(TextView)findViewById(R.id.desa_f5_qes_5);
		desa_f5_qes_6=(TextView)findViewById(R.id.desa_f5_qes_6);
		desa_f5_qes_7=(TextView)findViewById(R.id.desa_f5_qes_7);
		desa_f5_qes_8=(TextView)findViewById(R.id.desa_f5_qes_8);
		desa_f5_qes_9=(TextView)findViewById(R.id.desa_f5_qes_9);
		desa_f5_qes_10=(TextView)findViewById(R.id.desa_f5_qes_10);
		desa_f5_qes_11=(TextView)findViewById(R.id.desa_f5_qes_11);
		desa_f5_qes_12=(TextView)findViewById(R.id.desa_f5_qes_12);
		desa_f5_qes_13a=(TextView)findViewById(R.id.desa_f5_qes_13a);
		desa_f5_qes_13b=(TextView)findViewById(R.id.desa_f5_qes_13b);
		desa_f5_ans_1=(EditText)findViewById(R.id.desa_f5_ans_1);
		desa_f5_ans_2=(EditText)findViewById(R.id.desa_f5_ans_2);
		desa_f5_ans_3=(EditText)findViewById(R.id.desa_f5_ans_3);
		desa_f5_ans_4=(EditText)findViewById(R.id.desa_f5_ans_4);
		desa_f5_ans_6=(EditText)findViewById(R.id.desa_f5_ans_6);
		desa_f5_ans_8=(EditText)findViewById(R.id.desa_f5_ans_8);
		desa_f5_ans_10=(EditText)findViewById(R.id.desa_f5_ans_10);
		desa_f5_ans_11=(EditText)findViewById(R.id.desa_f5_ans_11);
		desa_f5_ans_12=(EditText)findViewById(R.id.desa_f5_ans_12);
		desa_f5_ans_13a=(EditText)findViewById(R.id.desa_f5_ans_13a);
		desa_f5_ans_13b=(EditText)findViewById(R.id.desa_f5_ans_13b);
		desa_f5_ans_5a=(CheckBox)findViewById(R.id.desa_f5_ans_5a);
		desa_f5_ans_5b=(CheckBox)findViewById(R.id.desa_f5_ans_5b);
		desa_f5_ans_5c=(CheckBox)findViewById(R.id.desa_f5_ans_5c);
		desa_f5_ans_5d=(CheckBox)findViewById(R.id.desa_f5_ans_5d);
		desa_f5_ans_9a=(CheckBox)findViewById(R.id.desa_f5_ans_9a);
		desa_f5_ans_9b=(CheckBox)findViewById(R.id.desa_f5_ans_9b);
		desa_f5_ans_9c=(CheckBox)findViewById(R.id.desa_f5_ans_9c);
		desa_f5_ans_9d=(CheckBox)findViewById(R.id.desa_f5_ans_9d);
		desa_f5_ans_7a=(CheckBox)findViewById(R.id.desa_f5_ans_7a);
		desa_f5_ans_7b=(CheckBox)findViewById(R.id.desa_f5_ans_7b);
		desa_f5_qes_1.setOnClickListener(this);
		desa_f5_qes_2.setOnClickListener(this);
		desa_f5_qes_3.setOnClickListener(this);
		desa_f5_qes_4.setOnClickListener(this);
		desa_f5_qes_5.setOnClickListener(this);
		desa_f5_qes_6.setOnClickListener(this);
		desa_f5_qes_7.setOnClickListener(this);
		desa_f5_qes_8.setOnClickListener(this);
		desa_f5_qes_9.setOnClickListener(this);
		desa_f5_qes_10.setOnClickListener(this);
		desa_f5_qes_11.setOnClickListener(this);
		desa_f5_qes_12.setOnClickListener(this);
		desa_f5_qes_13a.setOnClickListener(this);
		desa_f5_qes_13b.setOnClickListener(this);
		desa_f5_ans_1.setOnClickListener(this);
		desa_f5_ans_2.setOnClickListener(this);
		desa_f5_ans_3.setOnClickListener(this);
		desa_f5_ans_4.setOnClickListener(this);
		desa_f5_ans_6.setOnClickListener(this);
		desa_f5_ans_8.setOnClickListener(this);
		desa_f5_ans_10.setOnClickListener(this);
		desa_f5_ans_11.setOnClickListener(this);
		desa_f5_ans_12.setOnClickListener(this);
		desa_f5_ans_13a.setOnClickListener(this);
		desa_f5_ans_5a.setOnClickListener(this);
		desa_f5_ans_5b.setOnClickListener(this);
		desa_f5_ans_5c.setOnClickListener(this);
		desa_f5_ans_5d.setOnClickListener(this);
		desa_f5_ans_9a.setOnClickListener(this);
		desa_f5_ans_9b.setOnClickListener(this);
		desa_f5_ans_9c.setOnClickListener(this);
		desa_f5_ans_9d.setOnClickListener(this);
		desa_f5_ans_7a.setOnClickListener(this);
		desa_f5_ans_7b.setOnClickListener(this);
		desa_f5_ans_1.setFocusable(false);
		desa_f5_ans_2.setFocusable(false);
		desa_f5_ans_3.setFocusable(false);
		desa_f5_ans_4.setFocusable(false);
		desa_f5_ans_6.setFocusable(false);
		desa_f5_ans_8.setFocusable(false);
		desa_f5_ans_10.setFocusable(false);
		desa_f5_ans_11.setFocusable(false);
		desa_f5_ans_12.setFocusable(false);
		desa_f5_ans_13a.setFocusable(false);
		next=(Button)findViewById(R.id.desa_f5_next);
		prev=(Button)findViewById(R.id.desa_f5_prev);
		next.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent=new Intent(getApplicationContext(),Desa_Form6.class);
				startActivity(intent);
				Desa_Form5.this.finish();
				
			}
		});
		prev.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent=new Intent(getApplicationContext(),Desa_Form4.class);
				startActivity(intent);
				Desa_Form5.this.finish();
				
			}
		});
	}
	public void toast_msg()
	{
		LayoutInflater inflater = getLayoutInflater();

		View layout = inflater.inflate(R.layout.custom_toast,
				(ViewGroup) findViewById(R.id.custom_toast_layout_id));
		TextView text = (TextView) layout.findViewById(R.id.text);
		text.setText(value);
		Toast toast = new Toast(getApplicationContext());
		toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
		toast.setDuration(Toast.LENGTH_LONG);
		toast.setView(layout);
		toast.show();
	}

	@Override
	public void onClick(View v) 
	{
		if(v.getId()==desa_f5_qes_1.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_1);
			toast_msg();
		}
		else if(v.getId()==desa_f5_qes_2.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_2);
			toast_msg();
		}else if(v.getId()==desa_f5_qes_3.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_3);
			toast_msg();
		}else if(v.getId()==desa_f5_qes_4.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_4);
			toast_msg();
		}else if(v.getId()==desa_f5_qes_5.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_5);
			toast_msg();
		}else if(v.getId()==desa_f5_qes_6.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_6);
			toast_msg();
		}else if(v.getId()==desa_f5_qes_7.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_7);
			toast_msg();
		}else if(v.getId()==desa_f5_qes_8.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_8);
			toast_msg();
		}else if(v.getId()==desa_f5_qes_9.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_9);
			toast_msg();
		}else if(v.getId()==desa_f5_qes_10.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_10);
			toast_msg();
		}else if(v.getId()==desa_f5_qes_11.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_11);
			toast_msg();
		}else if(v.getId()==desa_f5_qes_12.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_12);
			toast_msg();
		}else if(v.getId()==desa_f5_qes_13a.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_13a);
			toast_msg();
		}else if(v.getId()==desa_f5_qes_13b.getId())
		{
			value=getResources().getString(R.string.desa_f5_qes_13b);
			toast_msg();
		}else if(v.getId()==desa_f5_ans_1.getId())
		{
			msg_f5_ans_1();
		}else if(v.getId()==desa_f5_ans_2.getId())
		{
			msg_f5_ans_2();
		}else if(v.getId()==desa_f5_ans_3.getId())
		{
			msg_f5_ans_3();
		}else if(v.getId()==desa_f5_ans_4.getId())
		{msg_f5_ans_4();
			
		}else if(v.getId()==desa_f5_ans_6.getId())
		{
			msg_f5_ans_6();
			
		}else if(v.getId()==desa_f5_ans_8.getId())
		{
			msg_f5_ans_8();
		}else if(v.getId()==desa_f5_ans_10.getId())
		{
			msg_f5_ans_10();
		}else if(v.getId()==desa_f5_ans_11.getId())
		{
			msg_f5_ans_11();
		}else if(v.getId()==desa_f5_ans_12.getId())
		{
			msg_f5_ans_12();
		}else if(v.getId()==desa_f5_ans_13a.getId())
		{
			msg_f5_ans_13a();
		}
		else if(v.getId()==desa_f5_ans_5a.getId())
		{
			desa_f5_ans_5a.setChecked(false);
			msg_f5_ans_5();
		}
		else if(v.getId()==desa_f5_ans_5b.getId())
		{
			desa_f5_ans_5b.setChecked(false);
			msg_f5_ans_5();
		}
		else if(v.getId()==desa_f5_ans_5c.getId())
		{
			desa_f5_ans_5c.setChecked(false);
			msg_f5_ans_5();
		}
		else if(v.getId()==desa_f5_ans_5d.getId())
		{
			desa_f5_ans_5d.setChecked(false);
			msg_f5_ans_5();
		}
		else if(v.getId()==desa_f5_ans_9a.getId())
		{
			desa_f5_ans_9a.setChecked(false);
			msg_f5_ans_9();
		}
		else if(v.getId()==desa_f5_ans_9b.getId())
		{
			desa_f5_ans_9b.setChecked(false);
			msg_f5_ans_9();
		}
		else if(v.getId()==desa_f5_ans_9c.getId())
		{
			desa_f5_ans_9c.setChecked(false);
			msg_f5_ans_9();
		}
		else if(v.getId()==desa_f5_ans_9d.getId())
		{
			desa_f5_ans_9d.setChecked(false);
			msg_f5_ans_9();
		}
		else if(v.getId()==desa_f5_ans_7a.getId())
		{
			desa_f5_ans_7a.setChecked(false);
			msg_f5_ans_7();
		}
		else if(v.getId()==desa_f5_ans_7b.getId())
		{
			desa_f5_ans_7b.setChecked(false);
			msg_f5_ans_7();
		}
		
	}
	private void msg_f5_ans_1() {
	     Builder builder = new AlertDialog.Builder(this);
	     builder.setTitle("Select");
	     builder.setSingleChoiceItems(MSG_VALUES_1, -1, new DialogInterface.OnClickListener() {
	       

		@Override
	       public void onClick(DialogInterface dialog, int which) {
			 desa_f5_ans_1.setText(""+(which+1));
	         dialog.dismiss();
	         
	       }
	     });
	     builder.setNegativeButton("cancel",
	         new DialogInterface.OnClickListener() {
	           @Override
	           public void onClick(DialogInterface dialog, int which) {
	             dialog.dismiss();
	           }
	         });
	     AlertDialog alert = builder.create();
	     alert.show();
	   }
	private void msg_f5_ans_2() {
	     Builder builder = new AlertDialog.Builder(this);
	     builder.setTitle("Select");
	     builder.setSingleChoiceItems(MSG_VALUES_1, -1, new DialogInterface.OnClickListener() {
	       

		@Override
	       public void onClick(DialogInterface dialog, int which) {
			 desa_f5_ans_2.setText(""+(which+1));
	         dialog.dismiss();
	         
	       }
	     });
	     builder.setNegativeButton("cancel",
	         new DialogInterface.OnClickListener() {
	           @Override
	           public void onClick(DialogInterface dialog, int which) {
	             dialog.dismiss();
	           }
	         });
	     AlertDialog alert = builder.create();
	     alert.show();
	   }

	private void msg_f5_ans_3() {
	     Builder builder = new AlertDialog.Builder(this);
	     builder.setTitle("Select");
	     builder.setSingleChoiceItems(MSG_VALUES_3, -1, new DialogInterface.OnClickListener() {
	       

		@Override
	       public void onClick(DialogInterface dialog, int which) {
			 desa_f5_ans_3.setText(""+(which+1));
	         dialog.dismiss();
	         
	       }
	     });
	     builder.setNegativeButton("cancel",
	         new DialogInterface.OnClickListener() {
	           @Override
	           public void onClick(DialogInterface dialog, int which) {
	             dialog.dismiss();
	           }
	         });
	     AlertDialog alert = builder.create();
	     alert.show();
	   }

	private void msg_f5_ans_4() {
	     Builder builder = new AlertDialog.Builder(this);
	     builder.setTitle("Select");
	     builder.setSingleChoiceItems(MSG_VALUES_4, -1, new DialogInterface.OnClickListener() {
	       

		@Override
	       public void onClick(DialogInterface dialog, int which) {
			 desa_f5_ans_4.setText(""+(which+1));
	         dialog.dismiss();
	         
	       }
	     });
	     builder.setNegativeButton("cancel",
	         new DialogInterface.OnClickListener() {
	           @Override
	           public void onClick(DialogInterface dialog, int which) {
	             dialog.dismiss();
	           }
	         });
	     AlertDialog alert = builder.create();
	     alert.show();
	   }

	private void msg_f5_ans_6() {
	     Builder builder = new AlertDialog.Builder(this);
	     builder.setTitle("Select");
	     builder.setSingleChoiceItems(MSG_VALUES_6, -1, new DialogInterface.OnClickListener() {
	       

		@Override
	       public void onClick(DialogInterface dialog, int which) {
			 desa_f5_ans_6.setText(""+(which+1));
	         dialog.dismiss();
	         
	       }
	     });
	     builder.setNegativeButton("cancel",
	         new DialogInterface.OnClickListener() {
	           @Override
	           public void onClick(DialogInterface dialog, int which) {
	             dialog.dismiss();
	           }
	         });
	     AlertDialog alert = builder.create();
	     alert.show();
	   }

	private void msg_f5_ans_8() {
	     Builder builder = new AlertDialog.Builder(this);
	     builder.setTitle("Select");
	     builder.setSingleChoiceItems(MSG_VALUES_4, -1, new DialogInterface.OnClickListener() {
	       

		@Override
	       public void onClick(DialogInterface dialog, int which) {
			 desa_f5_ans_8.setText(""+(which+1));
	         dialog.dismiss();
	         
	       }
	     });
	     builder.setNegativeButton("cancel",
	         new DialogInterface.OnClickListener() {
	           @Override
	           public void onClick(DialogInterface dialog, int which) {
	             dialog.dismiss();
	           }
	         });
	     AlertDialog alert = builder.create();
	     alert.show();
	   }

	private void msg_f5_ans_10() {
	     Builder builder = new AlertDialog.Builder(this);
	     builder.setTitle("Select");
	     builder.setSingleChoiceItems(MSG_VALUES_10, -1, new DialogInterface.OnClickListener() {
	       

		@Override
	       public void onClick(DialogInterface dialog, int which) {
			 desa_f5_ans_10.setText(""+(which+1));
	         dialog.dismiss();
	         
	       }
	     });
	     builder.setNegativeButton("cancel",
	         new DialogInterface.OnClickListener() {
	           @Override
	           public void onClick(DialogInterface dialog, int which) {
	             dialog.dismiss();
	           }
	         });
	     AlertDialog alert = builder.create();
	     alert.show();
	   }

	private void msg_f5_ans_11() {
	     Builder builder = new AlertDialog.Builder(this);
	     builder.setTitle("Select");
	     builder.setSingleChoiceItems(MSG_VALUES_11, -1, new DialogInterface.OnClickListener() {
	       

		@Override
	       public void onClick(DialogInterface dialog, int which) {
			 desa_f5_ans_11.setText(""+(which+1));
	         dialog.dismiss();
	         
	       }
	     });
	     builder.setNegativeButton("cancel",
	         new DialogInterface.OnClickListener() {
	           @Override
	           public void onClick(DialogInterface dialog, int which) {
	             dialog.dismiss();
	           }
	         });
	     AlertDialog alert = builder.create();
	     alert.show();
	   }

	private void msg_f5_ans_12() {
	     Builder builder = new AlertDialog.Builder(this);
	     builder.setTitle("Select");
	     builder.setSingleChoiceItems(MSG_VALUES_12, -1, new DialogInterface.OnClickListener() {
	       

		@Override
	       public void onClick(DialogInterface dialog, int which) {
			 desa_f5_ans_12.setText(""+(which+1));
	         dialog.dismiss();
	         
	       }
	     });
	     builder.setNegativeButton("cancel",
	         new DialogInterface.OnClickListener() {
	           @Override
	           public void onClick(DialogInterface dialog, int which) {
	             dialog.dismiss();
	           }
	         });
	     AlertDialog alert = builder.create();
	     alert.show();
	   }

	private void msg_f5_ans_13a() {
	     Builder builder = new AlertDialog.Builder(this);
	     builder.setTitle("Select");
	     builder.setSingleChoiceItems(MSG_VALUES_13a, -1, new DialogInterface.OnClickListener() {
	       

		@Override
	       public void onClick(DialogInterface dialog, int which) {
			 desa_f5_ans_13a.setText(""+(which+1));
	         dialog.dismiss();
	         
	       }
	     });
	     builder.setNegativeButton("cancel",
	         new DialogInterface.OnClickListener() {
	           @Override
	           public void onClick(DialogInterface dialog, int which) {
	             dialog.dismiss();
	           }
	         });
	     AlertDialog alert = builder.create();
	     alert.show();
	   }
	 private void msg_f5_ans_5()
	   {
		     Builder builder = new AlertDialog.Builder(this);
		     builder.setTitle("Answer");
		     builder.setMultiChoiceItems(MSG_VALUES_5, selectVal5,
		         new DialogInterface.OnMultiChoiceClickListener()
		     {
		           @Override
		           public void onClick(DialogInterface dialog, int which,
		               boolean isChecked) 
		           {
		             selectVal5[which] = isChecked;
		           }
		         });
		     builder.setPositiveButton("Set", new DialogInterface.OnClickListener() {
		       @Override
		       public void onClick(DialogInterface dialog, int which) {
		         for (int i = 0; i <MSG_VALUES_5.length; i++) 
		         {
		           if (selectVal5[i]) 
		           {
		              if(i==0)
		 				{
		            	 
		 					desa_f5_ans_5a.setChecked(true);
	 					}
		 				else if(i==1)
		 				{
		 					desa_f5_ans_5b.setChecked(true);
		 				}
		 				else if(i==2)
		 				{
		 					desa_f5_ans_5c.setChecked(true);
		 				}
		 				else if(i==3)
		 				{
		 					desa_f5_ans_5d.setChecked(true);
		 				}
		           }
		           else
		           {
		        	   if(i==0)
		 				{
		            	 
		 					desa_f5_ans_5a.setChecked(false);
	 					}
		 				else if(i==1)
		 				{
		 					desa_f5_ans_5b.setChecked(false);
		 				}
		 				else if(i==2)
		 				{
		 					desa_f5_ans_5c.setChecked(false);
		 				}
		 				else if(i==3)
		 				{
		 					desa_f5_ans_5d.setChecked(false);
		 				}
		 				
		           }
		         }
		        }
		     });
		     builder.setNegativeButton("cancel",
		         new DialogInterface.OnClickListener() {
		           @Override
		           public void onClick(DialogInterface dialog, int which) {
		             dialog.dismiss();
		           }
		         });
		     AlertDialog alert = builder.create();
		     alert.show();
		   }
	 private void msg_f5_ans_7()
	   {
		     Builder builder = new AlertDialog.Builder(this);
		     builder.setTitle("Answer");
		     builder.setMultiChoiceItems(MSG_VALUES_7, selectVal7,
		         new DialogInterface.OnMultiChoiceClickListener()
		     {
		           @Override
		           public void onClick(DialogInterface dialog, int which,
		               boolean isChecked) 
		           {
		             selectVal7[which] = isChecked;
		           }
		         });
		     builder.setPositiveButton("Set", new DialogInterface.OnClickListener() {
		       @Override
		       public void onClick(DialogInterface dialog, int which) {
		         for (int i = 0; i <MSG_VALUES_7.length; i++) 
		         {
		           if (selectVal7[i]) 
		           {
		              if(i==0)
		 				{
		            	 
		 					desa_f5_ans_7a.setChecked(true);
	 					}
		 				else if(i==1)
		 				{
		 					desa_f5_ans_7b.setChecked(true);
		 				}
		           }
		           else
		           {
		        	   if(i==0)
		 				{
		            	 
		 					desa_f5_ans_7a.setChecked(false);
	 					}
		 				else if(i==1)
		 				{
		 					desa_f5_ans_7b.setChecked(false);
		 				}
		 				
		           }
		         }
		        }
		     });
		     builder.setNegativeButton("cancel",
		         new DialogInterface.OnClickListener() {
		           @Override
		           public void onClick(DialogInterface dialog, int which) {
		             dialog.dismiss();
		           }
		         });
		     AlertDialog alert = builder.create();
		     alert.show();
		   }
	 private void msg_f5_ans_9()
	   {
		     Builder builder = new AlertDialog.Builder(this);
		     builder.setTitle("Answer");
		     builder.setMultiChoiceItems(MSG_VALUES_9, selectVal9,
		         new DialogInterface.OnMultiChoiceClickListener()
		     {
		           @Override
		           public void onClick(DialogInterface dialog, int which,
		               boolean isChecked) 
		           {
		             selectVal9[which] = isChecked;
		           }
		         });
		     builder.setPositiveButton("Set", new DialogInterface.OnClickListener() {
		       @Override
		       public void onClick(DialogInterface dialog, int which) {
		         for (int i = 0; i <MSG_VALUES_9.length; i++) 
		         {
		           if (selectVal9[i]) 
		           {
		              if(i==0)
		 				{
		            	 
		 					desa_f5_ans_9a.setChecked(true);
	 					}
		 				else if(i==1)
		 				{
		 					desa_f5_ans_9b.setChecked(true);
		 				}
		 				else if(i==2)
		 				{
		 					desa_f5_ans_9c.setChecked(true);
		 				}
		 				else if(i==3)
		 				{
		 					desa_f5_ans_9d.setChecked(true);
		 				}
		           }
		           else
		           {
		        	   if(i==0)
		 				{
		            	 
		 					desa_f5_ans_9a.setChecked(false);
	 					}
		 				else if(i==1)
		 				{
		 					desa_f5_ans_9b.setChecked(false);
		 				}
		 				else if(i==2)
		 				{
		 					desa_f5_ans_9c.setChecked(false);
		 				}
		 				else if(i==3)
		 				{
		 					desa_f5_ans_9d.setChecked(false);
		 				}
		 				
		           }
		         }
		        }
		     });
		     builder.setNegativeButton("cancel",
		         new DialogInterface.OnClickListener() {
		           @Override
		           public void onClick(DialogInterface dialog, int which) {
		             dialog.dismiss();
		           }
		         });
		     AlertDialog alert = builder.create();
		     alert.show();
		   }
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		SharedPreferences preferences=getSharedPreferences("desa_f5_details",MODE_PRIVATE);
		SharedPreferences.Editor editor=preferences.edit();
		editor.putString("5_1", desa_f5_ans_1.getText().toString().trim());
		editor.putString("5_2", desa_f5_ans_2.getText().toString().trim());
		editor.putString("5_3", desa_f5_ans_3.getText().toString().trim());
		editor.putString("5_4", desa_f5_ans_4.getText().toString().trim());
		editor.putString("5_6", desa_f5_ans_6.getText().toString().trim());
		editor.putString("5_8", desa_f5_ans_8.getText().toString().trim());
		editor.putString("5_10", desa_f5_ans_10.getText().toString().trim());
		editor.putString("5_11", desa_f5_ans_11.getText().toString().trim());
		editor.putString("5_12", desa_f5_ans_12.getText().toString().trim());
		editor.putString("5_13a", desa_f5_ans_13a.getText().toString().trim());
		editor.putString("5_13b", desa_f5_ans_13b.getText().toString().trim());
		editor.putBoolean("5_5a",desa_f5_ans_5a.isChecked());
		editor.putBoolean("5_5c",desa_f5_ans_5c.isChecked());
		editor.putBoolean("5_5b",desa_f5_ans_5b.isChecked());
		editor.putBoolean("5_5d",desa_f5_ans_5d.isChecked());
		editor.putBoolean("5_7a",desa_f5_ans_7a.isChecked());
		editor.putBoolean("5_7b",desa_f5_ans_7b.isChecked());
		editor.putBoolean("5_9a",desa_f5_ans_9a.isChecked());
		editor.putBoolean("5_9b",desa_f5_ans_9b.isChecked());
		editor.putBoolean("5_9c",desa_f5_ans_9c.isChecked());
		editor.putBoolean("5_9d",desa_f5_ans_9d.isChecked());
		editor.commit();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		SharedPreferences preferences=getSharedPreferences("desa_f5_details",MODE_PRIVATE);
		desa_f5_ans_1.setText(preferences.getString("5_1",""));
		desa_f5_ans_2.setText(preferences.getString("5_2",""));
		desa_f5_ans_3.setText(preferences.getString("5_3",""));
		desa_f5_ans_4.setText(preferences.getString("5_4",""));
		desa_f5_ans_6.setText(preferences.getString("5_6",""));
		desa_f5_ans_8.setText(preferences.getString("5_8",""));
		desa_f5_ans_10.setText(preferences.getString("5_10",""));
		desa_f5_ans_11.setText(preferences.getString("5_11",""));
		desa_f5_ans_12.setText(preferences.getString("5_12",""));
		desa_f5_ans_13a.setText(preferences.getString("5_13a",""));
		desa_f5_ans_13b.setText(preferences.getString("5_13b",""));
		desa_f5_ans_5a.setChecked(preferences.getBoolean("5_5a",false));
		desa_f5_ans_5b.setChecked(preferences.getBoolean("5_5b",false));
		desa_f5_ans_5c.setChecked(preferences.getBoolean("5_5c",false));
		desa_f5_ans_5d.setChecked(preferences.getBoolean("5_5d",false));
		desa_f5_ans_7a.setChecked(preferences.getBoolean("5_7a",false));
		desa_f5_ans_7b.setChecked(preferences.getBoolean("5_7b",false));
		desa_f5_ans_9a.setChecked(preferences.getBoolean("5_9a",false));
		desa_f5_ans_9b.setChecked(preferences.getBoolean("5_9b",false));
		desa_f5_ans_9c.setChecked(preferences.getBoolean("5_9c",false));
		desa_f5_ans_9d.setChecked(preferences.getBoolean("5_9d",false));
	}


}
